package com.huan.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowCountSortMapper extends Mapper<LongWritable, Text,FlowBean,Text> {

    FlowBean k = new FlowBean();
    Text v = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //TODO 获取并切割
        String[] splits = value.toString().split( "\t" );


        //13975057813	11058	48243	59301
        //TODO 封装对象
        String phoneNum = splits[0];


        long upFlow = Long.parseLong( splits[1] );
        long downFlow = Long.parseLong( splits[2] );
        long sumFlow = Long.parseLong( splits[3] );

        v.set( phoneNum );

        k.setUpFlow( upFlow );
        k.setDownFlow( downFlow );
        k.setSumFlow( sumFlow );

        context.write( k,v );

    }
}
